//
//  VisitHouseMemberTableViewCell.m
//  Fangmm
//
//  Created by ChaoZhou on 16/3/15.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "VisitHouseMemberTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <UIButton+WebCache.h>
#import "HomePageUser.h"
#import "UserHomepageViewController.h"

@implementation VisitHouseMemberTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)rectCell
{
//    _memberInfoArray = [NSMutableArray array];
//    for (NSDictionary *dic in _memberArray)
//    {
//        HomePageUser *member = [[HomePageUser alloc]initWithDic:dic];
//        [_memberInfoArray addObject:member];
//    }
    switch (_memberArray.count)
    {
        case 1:
        {
            [_header_1 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[0]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            _header_2.hidden = YES;
            _header_3.hidden = YES;
        }
            break;
        case 2:
        {
            [_header_1 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[0]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [_header_2 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[1]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            _header_3.hidden = YES;
        }
            break;
        case 3:
        {
            [_header_1 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[0]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [_header_2 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[1]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [_header_3 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[2]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        }
            break;
            case 4:
        {
            [_header_1 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[0]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [_header_2 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[1]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
            [_header_3 sd_setBackgroundImageWithURL:[NSURL URLWithString:((HomePageUser*)_memberArray[2]).userAvatar] forState:UIControlStateNormal placeholderImage:[[UIImage imageNamed:@"houseown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        }
            break;
        default:
        {
        }
            break;
    }
}

- (IBAction)headerButtonClick:(UIButton *)sender
{
    UserHomepageViewController *userHomePageVC = [[UserHomepageViewController alloc]init];
    HomePageUser *member = _memberArray[sender.tag];
    userHomePageVC.userId = member.userId;
    userHomePageVC.userName = member.userName;
    [self.SuperViewController.navigationController pushViewController:userHomePageVC animated:YES];
}
@end
